/**
 * 
 */
package vanhoc.android.mediakool.custom.adapter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import vanhoc.android.medialcool.item.data.PlaylistItemData;
import vanhoc.android.medialcool.item.layout.PlaylistItemView;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

/**
 * @author Administrator
 *
 */
public class PlaylistAdapter extends ArrayAdapter<PlaylistItemData> {
	private Context pcontext;
	private ArrayList<PlaylistItemData> arrListPlaylistItem;
	
	//Bien luu id cua playlist chua bai hat dang dc choi (neu co)
	private int current_playlist_id;
	
	public PlaylistAdapter(Context context, int textViewResourceId,
			List<PlaylistItemData> objects) {
		super(context, textViewResourceId, objects);
		
		this.pcontext	=	context;
		this.arrListPlaylistItem	=	(ArrayList<PlaylistItemData>) objects;
	}

	public void setCurrentPlaylist(int pid){
		this.current_playlist_id	=	pid;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		PlaylistItemView itemView;
		
		itemView	=	new PlaylistItemView(pcontext);
		itemView.txtPlaylistTitle.setText(arrListPlaylistItem.get(position).getPlaylistTitle());
		itemView.setTag(arrListPlaylistItem.get(position).getPlaylistId());
		if (arrListPlaylistItem.get(position).getPlaylistId() == this.current_playlist_id) {
			itemView.current_playing_icon.setImageResource(vanhoc.android.mediakool.R.drawable.next_16_icon);
		}
		
		return itemView;
	}

	public void remove(int position) {
		arrListPlaylistItem.remove(position);
	}

}
